/* The link = http://poj.org/problem?id=1046
 * If the meaning of the problem could be understood correctly, then the solution comes up.
 */

#include <iostream>

using namespace std;

const int BASE = 16;
const int NUMBER_OF_COLOR = 3;
int baseColorSet[BASE][NUMBER_OF_COLOR];

int main(int argc, char *argv[])
{
	for (int i = 0; i < BASE; i++)
		cin >> baseColorSet[i][0] >> baseColorSet[i][1] >> baseColorSet[i][2];

	int r, g, b;
	while (cin >> r >> g >> b
		&& r != -1 && g != -1 && b != -1) {
			int selectedIndex = 0;
			int distanceSquare = 
				(r - baseColorSet[0][0]) * (r - baseColorSet[0][0]) +
				(g - baseColorSet[0][1]) * (g - baseColorSet[0][1]) +
				(b - baseColorSet[0][2]) * (b - baseColorSet[0][2]);
			for (int i = 1; i < BASE; i++) {
				int tempDistanceSquare =
					(r - baseColorSet[i][0]) * (r - baseColorSet[i][0]) +
					(g - baseColorSet[i][1]) * (g - baseColorSet[i][1]) +
					(b - baseColorSet[i][2]) * (b - baseColorSet[i][2]);
				if (tempDistanceSquare < distanceSquare) {
					distanceSquare = tempDistanceSquare;
					selectedIndex = i;
				}
			}
			printf("(%d,%d,%d) maps to (%d,%d,%d)\n", r, g, b, baseColorSet[selectedIndex][0], 
				baseColorSet[selectedIndex][1], baseColorSet[selectedIndex][2]);
	}
	return 0;
}